<?php

Route::group(['middleware' => ['web']], function () {

    Route::get('/', 'HomeController@index');
    Route::get('/reset_password', 'HomeController@index');         //强制跳转首页
    //个人中心
    Route::get('/user_index', 'HomeController@user');
    //账户中心
    Route::get('/user_money', 'HomeController@money');
    //充值
    Route::get('recharge','UserCenter\UserCenterController@recharge');
    Route::post('doRecharge','UserCenter\UserCenterController@doRecharge');
    //提现
    Route::get('withdraw','UserCenter\UserCenterController@withdraw');
    Route::post('doWithdraw','UserCenter\UserCenterController@doWithdraw');
    //icp icon
    Route::get('/icp_icon_one','HomeController@icpIconOne');
    Route::get('/icp_icon_two','HomeController@icpIconTwo');
    //我的投资
    Route::get('/projects', 'ProjectController@list');
    //我的贷款
    Route::get('/myBorrow', 'HomeController@myBorrow');
    //退出登录
    Route::get('/logout', 'HomeController@logout');
    //更多公告
    Route::get('/moreNotice', 'HomeController@moreNotice');
    //更多新手标
    Route::get('/moreBeginner', 'HomeController@moreBeginner');
    //对应新手标
    Route::get('/oneBeginner/{id}', 'HomeController@oneBeginner');
    //更多平台数据
    Route::get('/moreRecord', 'HomeController@moreRecord');
    //更多精选项目
    Route::get('/moreProjects', 'HomeController@moreProjects');
    //对应精选项目
    Route::get('/oneProjects/{id}', 'HomeController@oneProjects');
    Route::get('/invitation/{code}', 'Auth\AuthController@invitation');

    //二级经济人注册
    Route::get('/seondRegister/{code?}','Auth\AuthController@seondRegister');
    Route::post('/createAgent','Auth\AuthController@createAgent');

//    Route::group(['prefix'=>'login'],function(){
//       Route::get('/','LoginController@index');
//    });

    Route::group(['prefix' => 'articles'], function () {
        Route::get('help/{id?}', 'ArticleController@help');
        Route::get('help/{id}/info', 'ArticleController@help_article_info');
        Route::get('notice/{id?}', 'ArticleController@notice');
        Route::get('notice/{id}/info', 'ArticleController@notice_article_info');
        Route::get('about/{id?}', 'ArticleController@about');
        Route::get('xszc/{id?}', 'ArticleController@xszc');
        Route::get('/', 'ArticleController@index');
        Route::get('list/{id?}', 'ArticleController@list');
        Route::get('/info/{id}', 'ArticleController@article_information_info');
        Route::get('/like_tag/{article_type_id}/{tag}', 'ArticleController@article_query');
        Route::get('/article_guide','ArticleController@article_guide');
        Route::get('/information_phone','ArticleController@information_phone');
        Route::get('/yijifu','ArticleController@yijifu');
        Route::get('/SecurityGuarantee','ArticleController@SecurityGuarantee');
    });

    /*--------------用户认证-------------*/
    Route::group(['namespace' => 'Auth'], function () {
        Route::get('/register', 'AuthController@register');            //用户注册(页面)
        Route::post('/create', 'AuthController@create');               //创建用户
        Route::get('/login', 'AuthController@login');                   //用户登陆(页面)
        Route::post('/loginIn', 'AuthController@loginIn');               //用户登陆(登陆并跳转页面)
        Route::get('/loginOut', 'AuthController@loginOut');             //用户登出(登出并跳转页面)
        Route::get('/reset_password_one', 'AuthController@resetPasswordOne');             //忘记密码页面 第一步
        Route::get('/send_reset_password_msm', 'AuthController@sendResetPasswordMsm');             //手机发送验证码
        Route::get('/check_phone_number', 'AuthController@checkPhoneCode');                    //校验验证码
        Route::post('/reset_password_two', 'AuthController@resetPasswordTwo');             //忘记密码页面(第二步)
        Route::post('/reset_password', 'AuthController@resetPassword');             //忘记密码页面(第二步)
            });

    /*-------------工具类-----------------*/
    Route::group(['prefix' => 'utils', 'namespace' => 'Utils'], function () {
        Route::get('/images/{path}/{w}/{h}', function ($path, $w, $h) {                                                 //根据指定图片宽高处理并生成图片
            //对路径进行base64解密
            $path = base64_decode($path);
            $img = Image::make($path)->resize($w, $h);
            return $img->response('jpg');
        });
        Route::get('captcha', 'UtilsController@captcha');                                                               //获取验证码图片
        Route::get('captcha/check', 'UtilsController@captcha_check');                                                   //检验验证码是否正确 req [string $code] resp [boolean $result]
        Route::get('/bind_email/{email}/{time}', 'UtilsController@bindEmail');                                          //绑定邮箱操作
        Route::get('/user/emailvalidate/state', "UtilsController@emailvalidateState");                                  //返回当前用户邮箱绑定状态  resp [boolean]
        Route::get('/user/username/exists/{username?}', 'UtilsController@userNameExists');                              //检测一个登陆用户名是否存在 resp[boolean] 存在"false" 不存在"true"
        Route::get('/user/useremail/exists/{useremail?}', 'UtilsController@userEmailExists');                           //检测一个登陆用户名是否存在 resp[boolean] 存在"false" 不存在"true"
        Route::get('/user/userphonenumber/exists/{userphonenumber?} ', 'UtilsController@userPhoneNumberExists');        //检测一个登陆用户名是否存在 resp[boolean] 存在"false" 不存在"true"
        Route::get('/user/transition','UtilsController@transition');
    });

    /*-------------前台需要进行登陆验证的路由------------*/
    Route::group(['middleware' => ['auth']], function () {
        //投资人
        Route::get('/user/settings', 'UserCenter\UserCenterController@index');
        Route::get('/user/transfer_to_saving_pot/{id}', 'UserCenter\UserCenterController@transferToSavingPot');
        Route::get('/user/center', 'UserCenter\UserCenterController@center');
        Route::get('/user/gift/{type?}', 'UserCenter\UserCenterController@gift');
        Route::get('/user/invitation', 'UserCenter\UserCenterController@invitation');
        Route::get('/user/projects','UserCenter\UserCenterController@projects');
        Route::get('/user/recharge_record','UserCenter\UserCenterController@rechargeRecord');
        Route::get('/user/balance_of_payments','UserCenter\UserCenterController@balanceOfPayments');
        Route::get('/user/present_record','UserCenter\UserCenterController@presentRecord');
        Route::get('/user/generation_collection','UserCenter\UserCenterController@generationCollection');
        Route::get('/user/already_collection','UserCenter\UserCenterController@alreadyCollection');
        Route::get('/user/investment_projects/{type?}','UserCenter\UserCenterController@investmentProjects');
        Route::get('/user/projects/{id}/print_template','UserCenter\UserCenterController@printTemplate');
        Route::get('/piggy_bank_agreement','UserCenter\UserCenterController@piggyBankAgreement');
        Route::get('/sina_payment_protocol','UserCenter\UserCenterController@sinaPaymentProtocol');
        //经纪人
        Route::get('/agent/customer_management','UserCenter\AgentController@customerManagement');
        Route::get('/agent/income_distribution','UserCenter\AgentController@incomeDistribution');
        Route::get('/agent/customer_info/{id}','UserCenter\AgentController@customerInfo');
        Route::get('/agent/customer_invest_list/{id}','UserCenter\AgentController@customerInvestList');
        Route::get('/agent/business_manager','UserCenter\AgentController@businessManager');
        Route::get('/agent/nextAgent','UserCenter\AgentController@nextAgent');
        Route::get('/agent/nextAgentUser','UserCenter\AgentController@nextAgentUser');
        //融资人
        Route::get('/loaner/index','UserCenter\LoanerController@index');
        Route::get('/loaner/pending_repayment','UserCenter\LoanerController@pendingRepayment');
        Route::get('/loaner/already_repayment','UserCenter\LoanerController@alreadyRepayment');
        Route::get('/loaner/financing_management','UserCenter\LoanerController@financingManagement');
        Route::get('/loaner/repayment/{id}','UserCenter\LoanerController@repayment');

        /*user_validate start*/
        Route::post('/user/settings/modify_password','UserCenter\UserCenterController@modifyPassword');
        Route::post('/user/settings/setName','UserCenter\UserCenterController@setName');
        Route::post('/user/settings/setPhoneNumber','UserCenter\UserCenterController@setPhoneNumber');
        Route::post('/user/settings/unBindPhoneNumber','UserCenter\UserCenterController@unBindPhoneNumber');
        Route::get('/user/settings/sendPhoneCode','UserCenter\UserCenterController@sendPhoneCode');
        Route::post('/user/settings/sendEmailCode','UserCenter\UserCenterController@sendEmailLink');
        Route::get('/user/settings/setPayPassword','UserCenter\UserCenterController@setPayPassword');
        Route::get('/user/settings/setBank','UserCenter\UserCenterController@setBank');
        Route::post('/user/settings/binding_bank_card','UserCenter\UserCenterController@bindingBankCard');
        Route::post('/user/settings/binding_bank_card_advance','UserCenter\UserCenterController@bindingBankCardAdvance');
        Route::get('/user/settings/bank_in','UserCenter\UserCenterController@getBankInfo');
        Route::get('/user/settings/unbindingBankCard','UserCenter\UserCenterController@unbindingBankCard');
        Route::post('/user/settings/unbindingBankCardAdvance','UserCenter\UserCenterController@unbindingBankCardAdvance');
        Route::get('/user/settings/modifyPayPassword','UserCenter\UserCenterController@modifyPayPassword');
        Route::get('/user/settings/findPayPassword','UserCenter\UserCenterController@findPayPassword');
        Route::get('/user/settings/modifyVerifyMobile','UserCenter\UserCenterController@modifyVerifyMobile');
        /*end user_validate*/

        Route::group(['prefix' => 'user/messages'], function () {           //前台用户消息管理
            Route::get('/{message_type?}', 'MessageController@index');
            Route::post('/del', 'MessageController@delete_msg');
            Route::post('/read', 'MessageController@read_msg');
            Route::post('/read_all', 'MessageController@read_all_msg');
            Route::post('/clear', 'MessageController@clear_all_msg');
        });
        //投资项目
        Route::post('Project/investProject/{id}','ProjectController@investProject');
        //担保管理
        Route::get('guarantee/index','UserCenter\GuaranteeController@index');
        Route::get('guarantee/query_money','UserCenter\GuaranteeController@queryMoney');       //查询机构资产总览
        Route::get('guarantee/check/{id}','UserCenter\GuaranteeController@check');
        Route::post('guarantee/check/{id}','UserCenter\GuaranteeController@checkProject');
        Route::get('guarantee/createAgreement/{id}','UserCenter\GuaranteeController@createAgreement');
    });
    //获取用户投资红包
    Route::get('/getGift/{money}/{cate}','HomeController@getGift');
    //代收撤销回调
    Route::any('return/cancelTrade','ReturnController@cancelTrade');
    //撤销红包投资
    Route::any('return/cancelGift','ReturnController@cancelGift');
    //充值回调
    Route::any('return/recharge','ReturnController@recharge');
    //提现回调
    Route::any('return/investProject','ReturnController@investProject');
    //投资回调
    Route::any('return/withdraw','ReturnController@withdraw');
    //红包投资回调
    Route::any('return/investGift','ReturnController@investGift');
    //投资撤销回调
    Route::any('return/cancelInvest','ReturnController@cancelInvest');
    //代收还款回调
    Route::any('return/payment','ReturnController@payment');
    //代付还款回调
    Route::any('return/repayment','ReturnController@repayment');
    //代收完成回调
    Route::any('return/finish','ReturnController@finish');
    //分润回调
    Route::any('return/profit','ReturnController@profit');
    //发放现金红包回调
    Route::any('return/sendGift','ReturnController@sendGift');
    Route::any('return/index','ReturnController@index');

    //预期投资收益
    Route::post('getProfit','HomeController@getProfit');
    Route::get('/register_agreement', 'Auth\AuthController@registerAgreement');            //用户注册协议(页面)
    Route::get('/beifujin','HomeController@getfxbj');
});
